package cn.pugle.base.net.socket.client;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

/**
 * 客户端。 发送完数据 接收。这里都是阻塞的。
 * Created by tzp on 15-12-7.<br/>
 */
public class MyMassSendClient {


    public static void main(String[] args) {
        try (//jdk1.7 try with resource
             Socket socket = new Socket(CONS.inetAddress, CONS.SERVER_PORT);
             OutputStream out = socket.getOutputStream();
        ) {
            String me = socket.getLocalAddress().toString();
            System.out.println(me);
            out.write(me.getBytes(CONS.CHARSET_NAME));
            for (int i = 0; i <= 800000; i++) {
                out.write(i);
            }
            System.out.println(CONS.PROTOCOL_TAIL + "\n");
            out.write((CONS.PROTOCOL_TAIL + "\n").getBytes(CONS.CHARSET_NAME));

            System.out.println("---------------------------");

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
